//check email
function isEmail(str)
{
    var reg = /^([a-zA-Z0-9|\_|\-|\.])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,4}){1,2})$/;
    return reg.test(str);
}

//mask Layer
function maskLayer(color)
{
    if(!color){color='#ffffff';}
    var tmpMask = $('<div id="maskLayer"></div>');
    tmpMask.css({
        /*'width':$(document).width()+'px',*/
        'width':'100%',
        'height':$(document).height()+'px',
        'position':'absolute',
        'top':'0px',
        'left':'0px',
        'z-index':'60',
        'background-color':color,
        'filter':'alpha(opacity=50)',
        'opacity':'0.5'
    });
    $("body").prepend(tmpMask);
}

//mask Loading
function maskLoading()
{
    var tmpLoading = $('<div id="maskLoading"><p><img src="/img/home/loading_c.gif"></p></div>');
    tmpLoading.css({
        /*'width':$(document).width()+'px',*/
        'width':'100%',
        'height':$(document).height()+'px',
        'position':'absolute',
        'top':'0px',
        'left':'0px',
        'z-index':'61'
    });
    //var _left = ($(window).scrollLeft() + $(window).width()/2 - 16)+'px';
    var _top = ($(window).scrollTop() + $(window).height()/2 - 60)+'px';
    tmpLoading.children('p').css({"text-align":"center", "padding-top":_top});
    $("body").prepend(tmpLoading);
}

//clear mask layer
function clearMaskLayer()
{
    setTimeout("$('#maskLayer').fadeOut(500)",0);
    setTimeout("$('#maskLayer').remove()",500);
}

//clear mask layer
function clearMaskLoading()
{
    $('#maskLoading').remove();
}

function goTab(n, t)
{
    if( ! t){ t = 1; }
    $('#tab'+n+'_t_'+t).addClass('t_on').siblings().removeClass('t_on');
    $('#tab'+n+'_c_'+t).show().siblings('.tab'+n+'_c').hide();
}

function getIEVersion()
{
    var rv = -1;
    if(navigator.appName == 'Microsoft Internet Explorer')
    {
        var ua = navigator.userAgent;
        var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
        if (re.exec(ua) != null)
            rv = parseFloat( RegExp.$1 );
    }
    return rv;
}

function scrollToID(id, extra)
{
    var pos = $('#'+id).position();
    extra = parseInt(extra); if(isNaN(extra)){ extra = 0; }
    $('html,body').animate({scrollTop:(pos.top+extra)}, '600');
}

function isRadioChecked(n)
{
    var obj = document.getElementsByName(n);
    var flag = false;
    for(var i=0,j=obj.length; i<j; i++){
        if(obj[i].checked){
            flag = true;
            break;
        }
    }
    return flag;
}

function countWord(id)
{
    var tmp = $.trim($("#"+id).val());
    tmp = tmp.replace(/\s+/g, ' ');
    var content = tmp.split(" ");
    return content.length;
}